﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HZ.Supervise.Web.Meet
{
    public partial class MeetList_zx : BasePage
    {
        IBLL.IBLL_ProcureCatalog ihc = new HZ.Supervise.BLL.BLL_ProcureCatalog();
        IBLL.IBLL_User log = BLLFactory.BLL_User(); 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindList();
            }
        }

        private void BindList()
        {
            int totalCount = 0;
            string str = "";
            if (!string.IsNullOrEmpty(txtMeetName.Text.Trim()))
            {
                str += string.Format(" and MeetName like '%{0}%'", txtMeetName.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtStartTime.Text.Trim()))
            {
                str += string.Format(" and MeetStartTime>='{0}'", txtStartTime.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtEndTime.Text))
            {
                str += string.Format(" and MeetEndTime<='{0}'", txtEndTime.Text.Trim());
            }
            DataTable dt = ihc.GetMeetList(str, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
            AspNetPager1.RecordCount = totalCount;
            gvw.PageSize = AspNetPager1.PageSize;
            gvw.DataSource = dt;
            gvw.DataBind();
        }
        //添加会议
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Response.Redirect("MeetAdd.aspx");
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
        }

        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            BindList();
        }


        protected void btndelete_Click(object sender, EventArgs e)
        {
            if (Request["checkbox1"] == null)
            {
                HZ.Web.WebUtil.Alert("请至少勾选一项！", this);
            }
            else
            {
                string chkid = Request.Form["checkbox1"].ToString();
                if (ihc.DelMeet(chkid) == 1)
                {
                    HZ.Supervise.Model.KeyOperationLogJG keyOperationLog = new HZ.Supervise.Model.KeyOperationLogJG();
                    keyOperationLog.OperationLogSerialID = Guid.NewGuid().ToString();
                    keyOperationLog.Operator = CurrentAccount.GetUser().UserID;
                    keyOperationLog.OrgID = CurrentAccount.GetUser().Org.OrgID;
                    keyOperationLog.OperateTime = DateTime.Now;
                    keyOperationLog.OperateMessage = string.Format("删除会议[{0}]", chkid);
                    log.AddKeyOperationLog(keyOperationLog);
                }
                else
                {
                    HZ.Web.WebUtil.Alert("删除失败！");
                }
                BindList();
            }
        }
    }
}